from logging_config import setup_logger

logger = setup_logger(__name__)

def extract_image(image):
    width, height = image.size
    # logger.info(f"Original image dimensions: {width}x{height}")

    rescale_coeff = 640 / max(width, height)
    new_width, new_height = int(width * rescale_coeff), int(height * rescale_coeff)
    logger.info(f"Resizing image to: {new_width}x{new_height}")

    image = image.resize((new_width, new_height))

    rescale_coeff2 = 1024 / max(width, height)
    output_width, output_height = int(width * rescale_coeff2), int(height * rescale_coeff2)
    logger.info(f"Output dimensions set to: {output_width}x{output_height}")

    return image, output_height, output_width

